// 用户相关接口
import { request } from '../utils/request.js'

/*
    用户登录
    @params mobile 手机号
    @params code 验证码
*/

export const login = data => request({
  method: 'post',
  url: '/v1_0/authorizations',
  data
})

/**
 * 发送验证码
 * @params mobile 手机号
*/

export const getSmsCode = mobile => request({
  method: 'get',
  url: `/v1_0/sms/codes/${mobile}`
})

// 获取用户本人信息
export const getUserInfo = () => request({
  method: 'get',
  url: '/v1_0/user'
})

// 获取用户频道列表
export const getUserChannels = () => request({
  method: 'get',
  url: '/v1_0/user/channels'
})

/**
 * 关注用户
 * @params target 用户id
 */
export const addFollow = targetId => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: targetId
    }
  })
}

/**
 * 取消关注用户
 * @params target 用户id
 */
export const deleteFollow = targetId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${targetId}`
  })
}

// 获取用户频道列表
export const getUserProfile = () => request({
  method: 'get',
  url: '/v1_0/user/profile'
})
